<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang exam.index.view.header}</h3>
				</div>
				<div class="widget-content">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_enable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.enable}</a>
							<a href="javascript:void(null);" id="btn_disable_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.disable}</a>
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/exam/_pub" class="btn btn-small" {$dispatches[operations][add]}>{lang exam.index.view.operation.add}</a>
							<span class="help-inline">{lang exam.index.view.tips}</span>
						</div>
					</div>
					<hr>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/exam&page={$_var[page]}&psize={$_var[psize]}" method="post">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="20"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="70">{lang exam.index.view.th.pic}</th>
								<th width="70">{lang exam.index.view.th.no}</th>
					            <th>{lang exam.index.view.th.name}</th>
					            <th width="120">{lang exam.index.view.th.date}</th>
					            <th width="120">{lang exam.index.view.th.edit}</th>
					            <th width="100">{lang exam.index.view.th.type}</th>
					            <th width="50">{lang exam.index.view.th.status}</th>
					            <th width="140">{lang exam.index.view.th.operate}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $exams $_loop $exam}-->
							<tr class="item-row">
								<td>
						        	<input type="checkbox" class="fancy" name="cbxItem[]" title="{$exam[TITLE]}" value="{$exam[EXAMID]}"/>
		           				</td>
		           				<td>
		           					<a href="{$ADMIN_SCRIPT}/exam/_user&id={$exam[EXAMID]}{$search[nextquery]}">
									    <!--{if is_array($exam['FILE02'])}-->
									    <img src="{$exam[FILE02][0]}" data="{$exam[FILE02][4]}" style="width:65px; border:1px solid #ccc;" />
									    <!--{elseif is_array($exam['FILE01'])}-->
									    <img src="{$exam[FILE01][0]}" data="{$exam[FILE01][4]}" style="width:65px; border:1px solid #ccc;" />
									    <!--{else}-->
									    <img src="static/images/no-picture.jpg" width="65" style="width:65px;" />
									    <!--{/if}-->
								    </a>
							    </td>
		           				<td class="f14">{$exam[IDENTITY]}</td>
					            <td>
					            	<p class="thin f14">
					            		<span class="text-info">
					            			<strong>[
					            			<!--{if $exam['LIMITNUM'] == 0}-->{lang exam.index.view.td.limit.no}
					            			<!--{else}-->{lang exam.index.view.td.limit.text}{$exam[LIMITNUM]}{lang exam.index.view.td.limit.time}
					            			<!--{/if}-->
					            			]</strong>
					            		</span>
										<a href="{$ADMIN_SCRIPT}/exam/_user&id={$exam[EXAMID]}{$search[nextquery]}" class="{echo $exam['USER_COUNT'] > 0 ? 'text-success' : 'text-error';}">
											<strong>{$exam[TITLE]}</strong>
										</a>
									</p>
								    <p class="text-info thin">
								    	[{$exam[USER_COUNT]}{lang exam.index.view.td.user.count}]
								    	&nbsp;
									    <a href="javascript:void(null);" data="{$exam[IDENTITY]}" title="{$exam[TITLE]}" class="link-qr"><i class="icon-qrcode"></i>{lang exam.index.view.td.qrcode}</a> 
									    <!--{if $exam['ISAWARD'] > 0}-->
									    <a href="{$ADMIN_SCRIPT}/exam/_award&id={$exam[EXAMID]}" title="{$exam[TITLE]}" class="link-gift" target="_blank"><i class="icon-gift"></i>{lang exam.index.view.td.award}</a> 
									    <!--{/if}-->
								    </p>
								    <p class="muted thin">
									    <!--{if count($exam['CATEGORY']) > 0}-->
									    <!--{loop $exam['CATEGORY'] $ckey $category}-->
									    <span class="f14">
										    {$category[CNAME]}
										    <!--{if $category['NUM'] == 0}-->
										    ({lang exam.index.view.td.category.all})；
										    <!--{else}-->
										    ({$category[NUM]}{lang exam.index.view.td.category.unit})；
										    <!--{/if}-->
										</span>
									    <!--{/loop}-->
									    <!--{else}-->
									    	<span>{lang exam.index.view.td.option.all}</span>
									    <!--{/if}-->
								    </p>
					            </td>
					            <td class="f12">
						            {$exam[BEGINTIME]}<br/>
						            {$exam[ENDTIME]}
					            </td>
					            <td class="f12">{$exam[USERNAME]}<br/>{$exam[EDITTIME]}</td>
					            <td align="center">
					            	<!--{if $exam['RAND']}-->{lang exam.index.view.td.rand.yes}<!--{else}-->{lang exam.index.view.td.rand.no}<!--{/if}-->
					            	<!--{if $exam['ISAWARD']}-->{lang exam.index.view.td.isaward.yes}<!--{else}-->{lang exam.index.view.td.isaward.no}<!--{/if}-->
					            </td>
					            <td>{$exam[STATUS]}</td>
					            <td>
					            	<a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/exam/_update&id={$exam[EXAMID]}&page={$_var[page]}&psize={$_var[psize]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                <a class="btn btn-mini btn-delete" title="{$exam[TITLE]}" data="{$exam[EXAMID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
					                <a class="btn btn-mini" href="{$ADMIN_SCRIPT}/exam/_option&id={$exam[EXAMID]}{$search[nextquery]}" {$dispatches[operations][edit]}>{lang exam.index.view.td.button.option}</a>
					             </td>
							</tr>
							<!--{/loop}-->
							<!--{if $count == 0}-->
							<tr>
					            <td colspan="8">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
$(function(){
	$('.fancy').uniform();
	
	$('#btn_enable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + ' ； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.enable}', message:'<p>{lang exam.index.view.operation.enable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam&do=enable_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang exam.index.view.operation.empty}'});
	});
	
	$('#btn_disable_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title')  + ' ； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.disable}', message:'<p>{lang exam.index.view.operation.disable.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam&do=disable_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang exam.index.view.operation.empty}'});
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') +'； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang exam.index.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam&do=delete_list&page={$_var[page]}&psize={$_var[psize]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang exam.index.view.operation.empty}'});
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .link-qr').click(function(){
		var href = '<p class="f10">{lang exam.index.view.dialog.link}：{$setting[SiteHost]}mobile.do?ac=exam&id=' + $(this).attr('data') + '</p>';
		$.dialog({width:400, title:'{lang exam.index.view.dialog.qrcode}', message:'<div align="center" style="background:#e3e3e3; padding:30px 0;"><img src="{$ADMIN_SCRIPT}/exam/_qrcode&id=' + $(this).attr('data') + '" width="200" height="200" style="width:200px; height:200px;" border="0"/></div>' + href});
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var answerid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang exam.index.view.operation.delete.one}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam&do=delete&id=' + answerid + '&page={$_var[page]}&psize={$_var[psize]}');
				$('#frm_grid').submit();
			});
		}});
	});
});
</script>
<!--{template /module/admin/view/foot}-->